package com.pro.controller;

import com.pro.pojo.JsUserOrder;
import com.pro.pojo.JsonData;
import com.pro.service.JsUserReturnCompleteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * ClassName:JsUserReturnCompleteController
 * Package:com.pro.controller
 * Description: 退货已完成列表
 *
 * @Date:2021/11/12 下午 6:56
 * @Author: WYH
 */
@Controller
@RequestMapping("/returnComp")
public class JsUserReturnCompleteController {

    @Autowired
    private JsUserReturnCompleteService jsUserReturnCompleteService;

    /**
     * @author WYH
     * @date 2021/11/12 下午 7:02
     * @content : 查询退货已完成列表
     */
    @RequestMapping("/getAllReGoo")
    @ResponseBody
    public JsonData getAllReGoo(String orderPaymentChannel, String orderSource) {
        orderPaymentChannel = orderPaymentChannel  != null  ? "%"+orderPaymentChannel+"%":"%%";
        orderSource = orderSource = orderSource != null ? "%"+orderSource+"%":"%%";
        List<JsUserOrder> allCourse = jsUserReturnCompleteService.getAllReGoo(orderPaymentChannel, orderSource);
        int count = jsUserReturnCompleteService.count(orderPaymentChannel, orderSource);
        return allCourse != null ? JsonData.buildSuccess(allCourse,count):JsonData.buildError("服务端错误");
    }
    /**
     * @author WYH
     * @date 2021/11/12 下午 7:02
     * @content : 删除选中数据
     */
    @RequestMapping("/delReGoo")
    @ResponseBody
    public JsonData delReGoo(Integer orderId) {
        Boolean aBoolean = jsUserReturnCompleteService.delReGoo(orderId);
        return aBoolean!= false ? JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
}
